{
  "name": "Case 20 – Regulatory Compliance Self-Assessment",
  "nodes": [
    {
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2,
      "position": [0, 0],
      "parameters": {
        "formTitle": "Regulatory Compliance Self-Assessment",
        "formDescription": "Upload compliance documents for regulatory gap assessment",
        "formFields": {
          "values": [
            { "fieldLabel": "Company Name", "requiredField": true },
            { "fieldLabel": "Compliance Officer Name", "requiredField": true },
            { "fieldLabel": "Email id", "fieldType": "email", "requiredField": true },
            {
              "fieldLabel": "Compliance_Documents",
              "fieldType": "file",
              "acceptFileTypes": ".pdf",
              "requiredField": true
            }
          ]
        }
      }
    },
    {
      "name": "Upload file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [220, 0],
      "parameters": {
        "inputDataFieldName": "Compliance_Documents",
        "name": "={{ $json['Company Name'] + '_Compliance_Documents' }}",
        "folderId": "REPLACE_WITH_COMPLIANCE_DOCS_FOLDER_ID"
      }
    },
    {
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [420, 0],
      "parameters": {
        "operation": "download",
        "fileId": "={{ $json.id }}"
      }
    },
    {
      "name": "Extract Compliance Documents",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [620, 0],
      "parameters": {
        "operation": "pdf"
      }
    },
    {
      "name": "Download Regulatory Checklist",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [820, 0],
      "parameters": {
        "operation": "download",
        "fileId": "REPLACE_WITH_REGULATORY_CHECKLIST_FILE_ID"
      }
    },
    {
      "name": "Extract Regulatory Checklist",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [1020, 0],
      "parameters": {
        "operation": "pdf"
      }
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [220, 260],
      "parameters": {
        "promptType": "define",
        "text": "=Company Compliance Documents:\n{{ $('Extract Compliance Documents').item.json.text }}\n\nRegulatory Checklist & Compliance Requirements:\n{{ $('Extract Regulatory Checklist').item.json.text }}",
        "options": {
          "systemMessage": "You are a Senior Regulatory Compliance Auditor.\n\nYOUR OBJECTIVE:\nAssess whether the organization is compliant with applicable regulations by identifying control gaps, exposure areas, and remediation requirements, using a conservative, regulator-aligned risk lens.\n\nANALYSIS FRAMEWORK (MANDATORY):\n1. REGULATORY COVERAGE – completeness of compliance against mandatory requirements.\n2. CONTROL DESIGN – adequacy of policies, SOPs, and governance mechanisms.\n3. CONTROL OPERATING EFFECTIVENESS – evidence of execution, monitoring, and enforcement.\n4. RISK EXPOSURE – likelihood and impact of non-compliance (financial, legal, reputational).\n5. REMEDIATION READINESS – clarity, feasibility, and urgency of corrective actions.\n\nYOU MUST PRODUCE ONE JSON OBJECT WITH EXACTLY THESE FIELDS. ALL FIELDS ARE MANDATORY.\n\nJSON SCHEMA (STRICT):\n{\n  \"Company_Name\": \"string\",\n  \"Regulatory_Domain\": \"string\",\n  \"Assessment_Period\": \"string\",\n  \"Total_Regulatory_Requirements\": \"number\",\n  \"Requirements_Compliant\": \"number\",\n  \"Requirements_Non_Compliant\": \"number\",\n  \"Overall_Compliance_Level\": \"Low | Medium | High\",\n  \"Key_Compliance_Gaps\": \"string\",\n  \"Regulatory_Exposure_Risk\": \"Low | Medium | High\",\n  \"Remediation_Complexity\": \"Low | Medium | High\",\n  \"Final_Compliance_Status\": \"Compliant | Remediation Required\",\n  \"Auditor_Remarks\": \"string\"\n}\n\nINSTRUCTIONS:\n- Numeric fields MUST contain numbers only.\n- Do NOT add, remove, or rename fields.\n- Output ONLY valid JSON.\n- IMMEDIATELY call the Google Sheets Append Row tool using this JSON."
        }
      }
    },
    {
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [0, 420],
      "parameters": {
        "model": {
          "mode": "list",
          "value": "gpt-4.1-mini"
        }
      }
    },
    {
      "name": "Append row",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4,
      "position": [420, 460],
      "parameters": {
        "operation": "append",
        "documentId": "REPLACE_WITH_GOOGLE_SHEET_ID",
        "sheetName": "Regulatory Compliance Self-Assessment Register"
      }
    },
    {
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [420, 260],
      "parameters": {
        "sendTo": "={{ $('On form submission').item.json['Email id'] }}",
        "subject": "Regulatory Compliance Self-Assessment – Status",
        "message": "={{ 'Dear ' + $('On form submission').item.json['Compliance Officer Name'] + ',<br><br>Your regulatory compliance self-assessment has been completed based on the submitted documentation and applicable regulatory checklist. We will communicate remediation steps if required.<br><br>Compliance & Risk Team' }}"
      }
    }
  ],
  "connections": {
    "On form submission": { "main": [[{ "node": "Upload file" }]] },
    "Upload file": { "main": [[{ "node": "Download file" }]] },
    "Download file": { "main": [[{ "node": "Extract Compliance Documents" }]] },
    "Extract Compliance Documents": { "main": [[{ "node": "Download Regulatory Checklist" }]] },
    "Download Regulatory Checklist": { "main": [[{ "node": "Extract Regulatory Checklist" }]] },
    "Extract Regulatory Checklist": { "main": [[{ "node": "AI Agent" }]] },
    "OpenAI Chat Model": { "ai_languageModel": [[{ "node": "AI Agent" }]] },
    "Append row": { "ai_tool": [[{ "node": "AI Agent" }]] },
    "AI Agent": { "main": [[{ "node": "Send Email" }]] }
  },
  "active": false
}
